package win.smartown.app.weather;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import win.smartown.app.R;
import win.smartown.app.base.SuperActivity;
import win.smartown.app.weather.entity.Location;

/**
 * Created by smartown on 2017/5/8 13:42.
 * Desc:
 */
public class WeatherActivity extends SuperActivity {

    private List<Location> locations;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_weather);
        ViewPager viewPager = findView(R.id.weather_pager);

        locations = new ArrayList<>();
        locations.add(new Location("新都", "30.823499", "104.158705"));
        FragmentPagerAdapter adapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return WeatherFragment.newInstance(locations.get(position));
            }

            @Override
            public int getCount() {
                return locations.size();
            }

            @Override
            public void destroyItem(ViewGroup container, int position, Object object) {

            }
        };
        viewPager.setAdapter(adapter);
    }

}
